package com.sugon.service.impl;

import cn.hutool.core.util.RandomUtil;
import com.sugon.dao.FaultBaseDao;
import com.sugon.entity.FaultBaseEntity;
import com.sugon.service.FaultBaseService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.Date;
import java.util.List;
import java.util.Map;

/**
 * 设备故障库Service实现类
 *
 * @author sugon
 * @date 2019-07-31 16:38:41
 */
@Service("faultBaseService")
public class FaultBaseServiceImpl implements FaultBaseService {
    @Autowired
    private FaultBaseDao faultBaseDao;

    @Override
    public FaultBaseEntity queryObject(String id) {
        return faultBaseDao.queryObject(id);
    }

    @Override
    public List<FaultBaseEntity> queryList(Map<String, Object> map) {
        return faultBaseDao.queryList(map);
    }

    @Override
    public int queryTotal(Map<String, Object> map) {
        return faultBaseDao.queryTotal(map);
    }

    @Override
    public int save(FaultBaseEntity faultBase) {
        faultBase.setId(RandomUtil.randomString(32));
        faultBase.setFaultCode("FLT_"+new Date().getTime());
        faultBase.setDelFlag(1);
        return faultBaseDao.save(faultBase);
    }

    @Override
    public int update(FaultBaseEntity faultBase) {
        return faultBaseDao.update(faultBase);
    }

    @Override
    public int delete(String id) {
        return faultBaseDao.delete(id);
    }

    @Override
    public int deleteBatch(String[] ids) {
        return faultBaseDao.deleteBatch(ids);
    }
}
